
import 'package:date_format/date_format.dart';
import 'package:mysql1/src/results/row.dart';

class ErrorData {
  final int? ID;
  final DateTime? fDateTime;
  final String? fErrorCode;
  final String? fErrorName;

  ErrorData({
    this.ID,
    this.fDateTime,
    this.fErrorCode,
    this.fErrorName,
  });

  factory ErrorData.fromJson(Map<String, dynamic> json) {

    return ErrorData(
      ID: json['ID'], fDateTime: DateTime.parse(json['fDateTime'].toString()),
        fErrorCode: json['fErrorCode'] == null ? "" : json['fErrorCode'].toString(),
        fErrorName: json['fErrorName'] == null ? "" : json['fErrorName'].toString(),
    );
  }

  factory ErrorData.builder(ResultRow row) {
    return ErrorData(
      ID: row[0],
      fDateTime: row[1],
      fErrorCode: row[2].toString(),
      fErrorName: row[3].toString(),
    );
  }
}